package com.core.servicelayer;

import java.util.List;
import java.util.Set;

import com.core.protocols.IServiceLayerDelegate;
import com.core.utils.HibernateParameter;

public abstract class ServiceLayer {

	private IServiceLayerDelegate layerDelegate     = null;
	protected String              selectionCriteria = null;



	public IServiceLayerDelegate getLayerDelegate () {

		return layerDelegate;
	}



	public void setLayerDelegate ( IServiceLayerDelegate delegate ) {

		this.layerDelegate = delegate;
	}



	public String getSelectionCriteria () {

		return this.selectionCriteria;
	}



	public void setSelectionCriteria ( String value ) {

		this.selectionCriteria = value;
	}



	abstract public void performRequestWithFilter ( String predicate,
	                                                Set <HibernateParameter> requestParams );



	protected <T> void performResponse ( List <T> items,
	                                     Exception exception ) {

		if ( layerDelegate == null ) {
			System.out.println(String.format("%s.delegate==null", this.getClass().getCanonicalName()));
			return;
		}
		layerDelegate.responseResponseItemsList(items, this, exception);

	};
}
